package com.boomsecret.juc.collections;

import java.util.Iterator;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentSkipListMap;

/**
 * @author wangjinliang on 2019/1/22.
 */
public class ConcurrentSkipListMapDemo {
    private static ConcurrentSkipListMap<String, String> concurrentSkipListMap = new ConcurrentSkipListMap<>();

    public static void main(String[] args) {
        // 调表
        concurrentSkipListMap.put("cc", "cc");
        concurrentSkipListMap.put("dd", "dd");
        concurrentSkipListMap.put("bb", "bb");
        concurrentSkipListMap.put("aa", "aa");
        print(concurrentSkipListMap);
    }

    private static void print(ConcurrentSkipListMap<String, String> skipListMap) {
        Iterator<Entry<String, String>> iterator = skipListMap.entrySet().iterator();
        while (iterator.hasNext()) {
            Entry<String, String> next = iterator.next();
            System.out.println("key:" + next.getKey() + " value:" + next.getValue());
        }
    }
}
